package com.bw.unit3.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.bw.unit3.base.BaseBean
import com.bw.unit3.base.BaseViewModel
import com.bw.unit3.bean.BannerBean
import com.bw.unit3.http.HttpUtil
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

/**
 *
 * @ClassName: WelcomeViewModel
 * @Description: java类作用描述
 * @Author: zhangyanchao
 * @CreateDate: 2024/9/13 4:43 PM
 * @Version: 1.0
 */
class WelcomeViewModel : BaseViewModel() {

    val bannerLiveData = MutableLiveData<BaseBean<List<BannerBean>>>()

    fun getBanner() {
        viewModelScope.launch {
            withContext(Dispatchers.IO) {
                bannerLiveData.postValue(HttpUtil.apiService.getBanner())

            }
        }
    }
}